import type { IdDTO, SysBaseVO as SysBaseVO } from "../type/baseType";

/**
 * 菜单类型
 */
export enum SysMenuType {
    DIR = "1",
    ITEM = "2",
    BUTTON = "3",
}

/**
 * 菜单搜索筛选
 */
export interface SysMenuFiltDTO {
    name?: string
}

/**
 * 菜单编辑类型
 */
export interface SysMenuDTO extends IdDTO {
    name: string
    type: string
    path?: string
    component?: string
    icon?: string
    parentId?: string
    perms: string
    sort: number
    isHome?: boolean
    isShow?: boolean
}

/**
 * 菜单类型
 */
export interface SysMenuVO extends SysBaseVO {
    name: string
    type: string
    path?: string
    component?: string
    icon?: string
    parentId?: string
    perms: string
    sort: number
    isHome?: boolean
    isShow?: boolean
    children?: SysMenuVO[]
}

/**
 * 菜单VO转菜单DTO
 * @param sysMenuVO 
 * @returns 
 */
export const sysMenuVOToDTO = (sysMenuVO: SysMenuVO): SysMenuDTO => {
    return {
        id: sysMenuVO.id,
        name: sysMenuVO.name,
        type: sysMenuVO.type,
        path: sysMenuVO.path,
        component: sysMenuVO.component,
        icon: sysMenuVO.icon,
        parentId: sysMenuVO.parentId,
        perms: sysMenuVO.perms,
        sort: sysMenuVO.sort,
        isHome: sysMenuVO.isHome,
        isShow: sysMenuVO.isShow
    }
}